﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Interop;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Converters;
using System.Windows.Media.Composition;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using System.Windows.Shapes;
using System.Runtime.InteropServices;

namespace GadgetBase.Gadgets
{
    public class GadgetContainer : Popup
    {
        private SystemButtonPanel systemButtonPanel = new SystemButtonPanel();
        private Grid grid = new Grid();

        public GadgetContainer(Gadget gadget)
        {
            base.AllowsTransparency = true;
            base.StaysOpen = true;            
            base.Placement = PlacementMode.Center;
            base.Width = 100;
            base.Height = 100;
            
            systemButtonPanel.Name = "systemButtonPanel";
            systemButtonPanel.ResetSize();
            systemButtonPanel.Opacity = 0;
            systemButtonPanel.HorizontalAlignment = HorizontalAlignment.Right;
            systemButtonPanel.VerticalAlignment = VerticalAlignment.Top;

            ColumnDefinition column1 = new ColumnDefinition();
            column1.Width = GridLength.Auto;
            this.grid.ColumnDefinitions.Add(column1);
            ColumnDefinition column2 = new ColumnDefinition();
            column2.Width = new GridLength(systemButtonPanel.Width);            

            this.grid.Children.Add(gadget);
            Grid.SetColumn(this.systemButtonPanel, 1);
            this.grid.Children.Add(this.systemButtonPanel);

            base.Child = this.grid;
        }        
    }

    public class Gadget : Canvas
    {
        public Gadget()
        {
        }


        protected void SetBackground(string path)
        {
            ImageBrush brush = new ImageBrush(GlobalMethods.GetBitmapImage(path));
            this.Background = brush;
            this.Height = brush.ImageSource.Height;
            this.Width = brush.ImageSource.Width;
        }
    }
}

